/**
 * @description 配置文件
*/

const tianditu = require('./providers/tianditu.js')
const autonavi = require('./providers/autonavi.js')
const arcgis = require('./providers/arcgis.js')

module.exports = {
  // 服务端口
  PORT: 8100,
  // 允许的请求头
  allowHeaders: 'Origin,Accept-Language,Accept-Encoding,X-Forwarded-For,Connection,Accept,User-Agent,Host,Referer,Cookie,Content-Type,Cache-Control,Authorization,Token',
  // 是否支持跨域
  isCrossOrigin: true,
  isDynamicOrigin: false,
  // 项目目录
  // serverDir: __dirname + '/../',
  serverDir: __dirname + '/../../../../daelui-kennel/pigsty/df3s/dmapt/server',
  // 允许请求的目录
  accessDirs: [
    '/pages', '/static',
    // 前端访问
    {path: '/app/', replace: '/../app/'},
    // 普通路径访问
    {path: '/map/tile', replace: '/../xdata/map/tile'},
    // 天地图参数类型转换为路径
    {
      path: '/tianditu/',
      replace: [
        {match: /\/tianditu\/([\w_]+)/, replace: '/../xdata/map/tile/tianditu/$1'},
      ],
      query: [
        {match: /tilematrix=(\w+)/i, replace: '$1'},
        {match: /tilerow=(\w+)/i, replace: '$1'},
        {match: /tilecol=(\w+)/i, replace: '$1.png'},
      ]
    },
    // 高德地图参数类型转换为路径
    {
      path: '/autonavi/appmaptile',
      replace: '/../xdata/map/tile/autonavi',
      query: [
        {match: /vec=1/i, replace: 'vec/wmts'},
        {match: /img_w=1/i, replace: 'img_w/wmts'},
        {match: /cia_w=1/i, replace: 'cia_w/wmts'},
        {match: /z=(\w+)/i, replace: '$1'},
        {match: /x=(\w+)/i, replace: '$1'},
        {match: /y=(\w+)/i, replace: '$1.png'},
      ]
    }
  ],
  // 瓦片服务配置
  tile: {
    // path: __dirname + '/../../xdata/map/tile', // 瓦片存储目录
    path: __dirname + '/../../../../daelui-kennel/pigsty/df3s/dmapt/xdata/map/tile', // 瓦片存储目录
    rule: '{tilePath}/{layerMap}/{layerPath}', // 子路径规则，瓦片存储目录/图层地图标识名/图层路径
    // increasePath: __dirname + '/../../xdata/increase/tile', // 递增瓦片存储目录
    increasePath: __dirname + '/../../../../daelui-kennel/pigsty/df3s/dmapt/xdata/task', // 递增瓦片存储目录
    increaseRule: '{increasePath}/{yyyy}{MM}{dd}{HH}{mm}/{layerMap}/{layerPath}', // 递增子路径规则，瓦片存储目录/图层地图标识名/图层路径
    // taskPath: __dirname + '/../../xdata/task', // 存储任务目录
    taskPath: __dirname + '/../../../../daelui-kennel/pigsty/df3s/dmapt/xdata/task', // 存储任务目录
    speed: 10, // 请求并发数
    maps: [ // 地图集合
      tianditu,
      autonavi,
      arcgis
    ]
  }
}